<script>
	import Vue from 'vue'
	export default {
		data() {
			return {

			}
		},
		onLaunch: function() {

			this.getLangJson(this.$lang)
			this.hide_navbar()
			uni.addInterceptor('switchTab', {
				invoke(to) {
					setTimeout(() => {
						////执行判断token是否有效&跳转页面代码
						uni.$emit('switchTab', to)
					}, 50)
				},
				fail(err) {
					console.log(err)
				}
			})
			// #ifdef APP-PLUS
			const openinstall = uni.requireNativePlugin('openinstall-plugin');
			console.log('uni.requireNativePlugin',openinstall);
			openinstall.init();
			openinstall.registerWakeUp(function(result) {
				console.log('getWakeup : channel=' + result.channelCode + ', data=' + result.bindData);
			});
			openinstall.getInstall(
				8,
				function(result) {
					console.log('getInstall : channel=' + result.channelCode + ', data=' + result.bindData +
						', shouldRetry=' + result.shouldRetry);
				}
			);
			
			// #endif
			
		},
		onShow: function() {
			//console.log('App Show')
		},
		onHide: function() {
			//console.log('App Hide')
		},
		methods: {
			async getLangJson(lang) {
				var that = this
				let data = {
					lang
				}
				let [err, res] = await this.$httpas.get('/api/index/lang_data', data);
				if (res.data.code == 1) {
					uni.setStorageSync('localeJson', res.data.data);
					that.$i18n.setLocaleMessage(lang, res.data.data[lang])
					that.$i18n.locale = lang
				}
			},
			hide_navbar() {
				//#ifdef H5
				var ua = window.navigator.userAgent.toLowerCase();
				//公众号登录
				if (ua.match(/MicroMessenger/i) == 'micromessenger') {
					setTimeout(() => {
						let style = document.createElement('style');
						style.type = 'text/css';
						style.innerHTML = "uni-page-head,.uni-page-head{display:none;}";
						document.getElementsByTagName('head').item(0).appendChild(style);
					})
				}
				//#endif
			}
		}
	}
</script>

<style>
	/* #ifndef APP-PLUS-NVUE */
	@import url("./common/common.css");
	/* #endif */
</style>